package com.jt.www.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jt.www.domain.po.MarketerInfoEntity;
import com.jt.www.domain.po.TeamEntity;
import com.jt.www.domain.po.TeamMembersEntity;
import com.jt.www.util.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@ApiModel(description = "团队成员信息")
public class TeamMembersVO {

    @ApiModelProperty(value = "成员ID")
    private Long memberId;

    @ApiModelProperty(value = "创始人ID")
    private Long teamFounderId;

    @ApiModelProperty(value = "小队ID")
    private Long teamId;

    @ApiModelProperty(value = "小队名称")
    private String teamName;

    @ApiModelProperty(value = "工号")
    private String marketerNo;

    @ApiModelProperty(value = "营销人员姓名")
    private String marketerName;

    @ApiModelProperty(value = "营销人员手机号码")
    private String marketerPhone;

    @ApiModelProperty(value = "营销人员邮箱")
    private String marketerEmail;

    @ApiModelProperty(value = "渠道编码")
    private String channelCode;

    @ApiModelProperty(value = "渠道名称")
    private String channelName;

    @ApiModelProperty(value = "分支机构编码")
    private String branchCode;

    @ApiModelProperty(value = "分支机构名称")
    private String branchName;

    @ApiModelProperty(value = "部门编码")
    private String departCode;

    @ApiModelProperty(value = "部门名称")
    private String departName;

    @ApiModelProperty(value = "团队职级编码")
    private String levelCode;

    @ApiModelProperty(value = "团队职级名称")
    private String levelName;

    @ApiModelProperty(value = "入队时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date joinTime;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    public static TeamMembersVO convertEntity(TeamEntity team, TeamMembersEntity member, MarketerInfoEntity marketer) {

        TeamMembersVO vo = new TeamMembersVO();

        vo.setMemberId(member.getId());
        vo.setTeamFounderId(member.getTeamFounderId());
        vo.setTeamId(member.getTeamId());
        if (team != null) {
            vo.setTeamName(team.getTeamName());
        } else {
            vo.setTeamName("创始人直属");
        }
        vo.setMarketerNo(member.getMarketerNo());
        vo.setMarketerName(marketer.getMarketerName());
        vo.setMarketerPhone(marketer.getMarketerPhone());
        vo.setMarketerEmail(marketer.getMarketerEmail());
        vo.setChannelCode(marketer.getChannelCode());
        vo.setChannelName(marketer.getChannelName());
        vo.setBranchCode(marketer.getBranchCode());
        vo.setBranchName(marketer.getBranchName());
        vo.setDepartCode(marketer.getDepartCode());
        vo.setDepartName(marketer.getDepartName());
        vo.setLevelCode(member.getLevelCode());
        vo.setLevelName(member.getLevelName());
        vo.setJoinTime(StringUtils.isNotBlank(member.getJoinTime()) ? DateUtils.str2Date(member.getJoinTime(), DateUtils.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS) : null);
        vo.setCreateTime(DateUtils.str2Date(member.getCreateTime(), DateUtils.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS));

        return vo;
    }


    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getTeamFounderId() {
        return teamFounderId;
    }

    public void setTeamFounderId(Long teamFounderId) {
        this.teamFounderId = teamFounderId;
    }

    public Long getTeamId() {
        return teamId;
    }

    public void setTeamId(Long teamId) {
        this.teamId = teamId;
    }

    public String getTeamName() {
        return teamName;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    public String getMarketerNo() {
        return marketerNo;
    }

    public void setMarketerNo(String marketerNo) {
        this.marketerNo = marketerNo;
    }

    public String getMarketerName() {
        return marketerName;
    }

    public void setMarketerName(String marketerName) {
        this.marketerName = marketerName;
    }

    public String getMarketerPhone() {
        return marketerPhone;
    }

    public void setMarketerPhone(String marketerPhone) {
        this.marketerPhone = marketerPhone;
    }

    public String getMarketerEmail() {
        return marketerEmail;
    }

    public void setMarketerEmail(String marketerEmail) {
        this.marketerEmail = marketerEmail;
    }

    public String getChannelCode() {
        return channelCode;
    }

    public void setChannelCode(String channelCode) {
        this.channelCode = channelCode;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }

    public String getBranchCode() {
        return branchCode;
    }

    public void setBranchCode(String branchCode) {
        this.branchCode = branchCode;
    }

    public String getBranchName() {
        return branchName;
    }

    public void setBranchName(String branchName) {
        this.branchName = branchName;
    }

    public String getDepartCode() {
        return departCode;
    }

    public void setDepartCode(String departCode) {
        this.departCode = departCode;
    }

    public String getDepartName() {
        return departName;
    }

    public void setDepartName(String departName) {
        this.departName = departName;
    }

    public String getLevelCode() {
        return levelCode;
    }

    public void setLevelCode(String levelCode) {
        this.levelCode = levelCode;
    }

    public String getLevelName() {
        return levelName;
    }

    public void setLevelName(String levelName) {
        this.levelName = levelName;
    }

    public Date getJoinTime() {
        return joinTime;
    }

    public void setJoinTime(Date joinTime) {
        this.joinTime = joinTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
